package homeworke;

import java.io.*;
import java.util.Scanner;

public class Test1 {
    public static void main(String[] args) throws IOException {
        Scanner scanner = new Scanner(System.in);
        System.out.println("请输入姓名");
        String name= scanner.nextLine();
        System.out.println("请输入密码");
        String pwd = scanner.nextLine();
        System.out.println("请输入编号");
        String nick = scanner.nextLine();
        System.out.println("请输入年龄");
        int age = scanner.nextInt();
        User user = new User(name,pwd,nick,age);
        File file = new File(name);
        FileOutputStream fos = null;
        try {
            fos = new FileOutputStream(file);
        } catch (FileNotFoundException e) {
            e.printStackTrace();
        }
        ObjectOutputStream oos = new ObjectOutputStream(fos);
        oos.writeObject(user);
        System.out.println("写出完毕");
        oos.close();
    }

}
